Finding records that are not there - Mailing list pgsql-general

From Owen Hartnett
Subject Finding records that are not there
Date
Msg-id p06240802c45b4d152861@[192.168.0.100]
Whole thread Raw
Responses Re: Finding records that are not there  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: Finding records that are not there  ("Adam Rich" <adam.r@sbcglobal.net>)
Re: Finding records that are not there  ("Roberts, Jon" <Jon.Roberts@asurion.com>)
List pgsql-general
Hi:

This is gotta be elementary SQL 101, but I'm having a mental block as
to why this doesn't work.

I have two tables that have identical index fields, maplot and
unitno, (both indexes span two columns) and I want to find all the
records in the commcost table that don't have a corresponding record
in the bldg file.

The SQL I've tried is:

select commcost.maplot, commcost.unitno from commcost
where not exists(select 1 from commcost, bldg
where commcost.maplot = bldg.maplot and
commcost.unitno = bldg.unitno)
order by commcost.maplot

It returns no records although I know that there are records in
commcost which do not match keys with records from bldg.

Help!  What am I doing wrong?

-Owen

pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: Installed pgadmin3-1.4.3 with 8.3.1 database..errors
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: Finding records that are not there